/**
 * 2009-12-23 下午08:59:46 
 * esignature
 * com.smc.server.impl
 * CertificationServiceImpl
 */
package com.smc.server.impl;

import java.util.List;

import com.smc.dao.CertificationDao;
import com.smc.domain.model.Certification;
import com.smc.server.CertificationService;
import com.smc.signature.Certificate;

/**
 * @author chenheng
 * @version 0.0.1
 */
public class CertificationServiceImpl implements CertificationService {
	
	private CertificationDao certDao ;
	private Certificate certificate ;
	
	public CertificationDao getCertDao() {
		return certDao;
	}
	public void setCertDao(CertificationDao certDao) {
		this.certDao = certDao;
	}

	public Certificate getCertificate() {
		return certificate;
	}
	public void setCertificate(Certificate certificate) {
		this.certificate = certificate;
	}
	
	/* (non-Javadoc)
	 * @see com.smc.server.CertificationService#save_US_CE_SA_certification(com.smc.domain.model.Certification)
	 */
	public void save_US_CE_SA_certification(Certification cert) {
		certDao.saveCertificate(cert);
	}
	public int count_AD_IG_FE_certification(boolean authorized) {
		return certDao.countCertification(authorized);
	}
	public List<Certification> fetch_AD_IG_FE_cerification(boolean authorized, int pageIndex, int pageSize) {	
		return certDao.listCertification(authorized, pageIndex, pageSize);
	}
	
	public void remove_AD_IG_RE_certification(String uuid) {
		Certification cert = certDao.getCertByUuid(uuid);
		certificate.certDelete(cert.getAlias());
		certDao.deleteCertification(uuid);
	}
	
	public void authority_AD_IG_SA_certification(String uuid) {
		Certification cert = certDao.getCertByUuid(uuid);
		certificate.genkey(cert.getAlias(), cert.getDname(),cert.getKeyalg(),cert.getKeysize(),cert.getSigalg(), cert.getValidity(), cert.getKeypass());
		cert.setAuthorized(true);
		certDao.updateCertification(cert);
	}
	public Certification fetch_US_CE_FE_certification(String alias) {
		return certDao.getCertByAlias(alias);
	}
	

}
